﻿#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>

void ​Reverse(char ch[], int left, int right)//实现字符串逆序
{
	while (left < right)
	{
		char tmp = ch[left];
		ch[left] = ch[right];
		ch[right] = tmp;
		left++;
		right--;
	}
}

int main()
{
	char ch[100] = { 0 };
	int k = 0; 
	scanf("%s", ch);
	scanf("%d", &k);
	size_t len = strlen(ch);
	int time = k % len;
	​Reverse(ch, 0, time - 1);//把前(K % leng)个字符逆序
	​Reverse(ch, time, len - 1);//把前(K % leng)个字符后的字符逆序
	​Reverse(ch, 0, len - 1);//再把整个字符串整体逆序

	//比如ABCDE左旋2个字符
	//把前两个字符逆序得到BACDE
	//再把前两个字符后的字符逆序得到BAEDC
	//再把字符串整体逆序得到CDEAB

	printf("%s", ch);
	return 0;
}